package com.zzyl.task;

import com.zzyl.nursing.mapper.ContractMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class DemoTask {

    @Autowired
    private ContractMapper contractMapper;

    @Scheduled(cron = "0 0 1 * * ? ")
    public void runTask() {
        log.info("---------开始检查---------");
        int count = contractMapper.updateStatusStart();
        if (count > 0) {
            log.info("---------合同已生效---------");
        }
        count = contractMapper.updateStatusLose();
        if (count > 0) {
            log.info("---------合同已失效---------");
        }
        count = contractMapper.updateStatusPast();
        if (count > 0) {
            log.info("---------合同已过期---------");
        }
    }
}
